package org.opens;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.opens.entity.EduClass;
import org.opens.service.EduClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Date 2021/3/3 15:54
 * @Created by 99126
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {MybatisCommonApplication.class})
public class UseProcedure {

    @Autowired
    private EduClassService eduClassService;

    @Test
    public void test1() {
        EduClass eduClass = new EduClass();
        eduClass.setClassId(1);
        EduClass result = eduClassService.findByIdUseProcedure(eduClass);
        System.out.println(eduClass);
        System.out.println(result);
    }

    @Test
    public void test2() {
        Map<String, Object> param = new HashMap<>();
        param.put("offset", 10);
        param.put("limit", 10);
        param.put("className", "qq");
        List<EduClass> eduClasses = eduClassService.pageUseProcedure(param);
        System.out.println(eduClasses);
        // 调用存储过程后，如果参数类型是map，则会把输出参数put到map中；
        System.out.println("total: " + param.get("total"));
    }

    @Test
    public void testDelete() {
        int deleteRowsCount = eduClassService.deleteUseProcedure(9);
        System.out.println(deleteRowsCount);
    }

    @Test
    public void testInsert() {
        EduClass eduClass = new EduClass();
        eduClass.setClassName("aaa1");
        eduClass.setCourseId(54);
        int result = eduClassService.insertUseProcedure(eduClass);
        System.out.println(eduClass);
        System.out.println(result);
    }

}
